# 字典是无序的

#1. 定义字典 {key:value,...} 键值对
dict_01 = {
    "name":"参赛复习",
    "age":18,
    "wife":"zdy",
    "son":"wsc",
    "money":1831093890129
}

#2. 通过key访问value
# print(dict_01["wife"])

#3. in , not in , len()
# print("age" not in dict_01)
# print(len(dict_01))

#4. 遍历字典
# 遍历key
for key in dict_01:
    print(key)

# 遍历key , value
for key in dict_01:
    print(key,dict_01[key])

# 5. 常用的增删改查操作
#增
dict_01["house"] = "大别墅"
print(dict_01)
#删
del dict_01["age"]
print(dict_01)
#改
dict_01["house"] = "江景大平层"
print(dict_01)
#查 遍历,通过key去取value

#6. 字典的常用方法
# dict_01.clear()
# print(dict_01)

dict_02 = dict_01.copy()
print(dict_02)

# dict_03 = dict.fromkeys(("age","name"),10)
# print(dict_03)

print(dict_02.get("house"))

print(dict_02.keys())
print(dict_02.values())
print(dict_02.items())
for key,value in dict_02.items():
    print(key,value)

